package org.massdgames.thunder.server.domain.strategy;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.massdgames.thunder.server.domain.Card;
import org.massdgames.thunder.server.domain.CardType;
import org.massdgames.thunder.server.domain.Deck;

public class BasicGuardianLoadStrategy implements GuardianLoadStrategy {

    public Deck load(Deck deck) throws IOException {
        Properties properties = new Properties();
        properties.load(new FileInputStream("deck.properties"));
        
        int guardianCount = new Integer(
                properties.getProperty("guardian.count"));

        for (int i = 0; i < guardianCount; i++) {
            Card guardianCard = new Card();
            guardianCard.setCardId(i);
            guardianCard.setName(properties.getProperty("guardian." + i
                    + ".name"));
            guardianCard.setCardType(CardType.GUARDIAN);
            deck.addCard(guardianCard);
        }

        return deck;
    }

}
